const Mock = require('mockjs')

const data = Mock.mock({
  'items|30': [{
    id: Mock.Random.id(),
    name: Mock.Random.cname(),
    age: Mock.Random.integer(18, 60),
    address: Mock.Random.county(true),
    createTime: Mock.Random.datetime()
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/vue-admin-template/table/addTableData',
    type: 'post',
    response: config => {
      const items = data.items
      const newData = config.body;
      // console.log(newData,"newData");
      newData.id = Mock.Random.id();
      items.push(newData);
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },


  
]
